﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using EasyStudy.Logic;

namespace EasyStudy.UI
{
    public partial class FrmQueryTask : KryptonForm
    {
        private StringBuilder sb;
        private string queryDate;
        private DataTable table;

        public DataTable DataSource
        {
            get { return table; }
        }

        private DataTable ExecuteQuery()
        {
            sb.Remove(0, sb.Length);
            sb.Append("CREATE_TIME like ");
            sb.Append("'" + calendar.SelectionEnd.ToString("yy-MM-dd") + "%'");

            return EbbTaskDBMgr.ExecuteAQuery(sb.ToString());
        }

        public FrmQueryTask()
        {
            InitializeComponent();

            sb = new StringBuilder();
            sb.AppendLine("查询日期");
            sb.AppendLine(calendar.SelectionEnd.ToString("yy-MM-dd"));
            txtConsole.Text = sb.ToString();
        }

        private void calendar_DateChanged(object sender, DateRangeEventArgs e)
        {
            sb.Remove(0, sb.Length);
            sb.AppendLine("查询日期");
            queryDate = e.End.ToString("yy-MM-dd");
            sb.AppendLine(queryDate);

            txtConsole.Text = sb.ToString();
        }

        private void btnQuery_Click(object sender, EventArgs e)
        {
            table = ExecuteQuery();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void kryptonButton2_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
